package io.adrainty.bolee.trade.feign.impl;

import io.adrainty.bolee.framework.commons.basic.ResultDTO;
import io.adrainty.bolee.framework.commons.utils.ResultDTOUtil;
import io.adrainty.bolee.trade.feign.ICommonPayFeign;
import io.adrainty.bolee.trade.handler.IPayHandler;
import io.adrainty.bolee.trade.handler.PayHandlerRegistry;
import io.adrainty.bolee.trade.models.entity.RefundRecordEntity;
import io.adrainty.bolee.trade.models.entity.TradeEntity;
import io.adrainty.bolee.trade.service.ITradeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author AdRainty
 * @version V1.0.0
 * @since 2025/8/31 下午11:13
 */

@Tag(name = "通用支付feign接口")
@RestController
@RequestMapping("/trade-common-feign")
public class CommonPayFeignImpl implements ICommonPayFeign {

    @Resource
    private PayHandlerRegistry handlerRegistry;

    @Resource
    private ITradeService tradeService;

    @Override
    @Operation(summary = "查询交易")
    @PostMapping("/query")
    public ResultDTO<TradeEntity> queryTrade(@RequestBody TradeEntity tradeVO) {
        return null;
    }

    @Override
    @PostMapping("/refund")
    @Operation(summary = "退款")
    public ResultDTO<TradeEntity> refundTrade(@RequestBody TradeEntity tradeVO) {
        return null;
    }

    @Override
    @PostMapping("/query-refund")
    @Operation(summary = "查询退款")
    public ResultDTO<RefundRecordEntity> queryRefundTrade(@RequestBody RefundRecordEntity refundRecordEntity) {
        return null;
    }

    @Override
    @PostMapping("/close")
    @Operation(summary = "关闭交易")
    public ResultDTO<TradeEntity> closeTrade(@RequestBody TradeEntity tradeVO) {
        IPayHandler payHandler = handlerRegistry.strictGetPayChannel(tradeVO.getTradeChannel());
        TradeEntity result = payHandler.closeTrade(tradeVO);
        return ResultDTOUtil.success(result);
    }

    @Override
    @PostMapping("/download-bill")
    @Operation(summary = "下载对账单")
    public ResultDTO<String> downLoadBill(@RequestBody TradeEntity tradeVO) {
        return null;
    }

    @Override
    @PostMapping("/sync-payment-job")
    @Operation(summary = "同步支付任务")
    public ResultDTO<Boolean> syncPaymentJob() {
        return null;
    }
}
